﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using System.Xml.Linq;
using System.Collections.Generic;

using YouHP.Model;
using YouHP.BLL;
using YouHP.Model.Group;

namespace web.admin
{
    public partial class GroupType : System.Web.UI.Page
    {
        private GroupTypeBLL groupTypeBll = GroupTypeBLL.Instance;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.ViewState["keyWordParm"] = "";

                bind(this.ViewState["keyWordParm"].ToString());
            }
        }

        protected void search_Click(object sender, EventArgs e)
        {
            this.ViewState["keyWordParm"] = this.keyWord.Text.Trim();

            bind(this.ViewState["keyWordParm"].ToString());
        }

        private void bind(string keyword)
        {
            List<GroupTypeInfo> list = null;

            try
            {
                list = groupTypeBll.GetAllGroupTypeByName(keyword);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            this.groupTypeList.DataSource = list;
            this.groupTypeList.DataBind();
        }

        protected void pageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.groupTypeList.PageIndex = e.NewPageIndex;
            bind(this.ViewState["keyWordParm"].ToString());
        }
    }
}
